package ru.lenwp.util;

import java.sql.Date;
import java.util.Calendar;

/**
 * Created by Lenar on 30.09.2014.
 */
public class DateUtil {
    public static Date toSqlDate(java.util.Date date){
        return new Date(date.getTime());
    }

    public static java.util.Date toUtilDate(Date date){
        return new java.util.Date(date.getTime());
    }

    public static java.util.Date trunk(java.util.Date date){
        if(date == null){
            return null;
        }
        Calendar cal = Calendar.getInstance();
        cal.setTime(date);
        cal.set(Calendar.HOUR_OF_DAY, 0);
        cal.set(Calendar.MINUTE, 0);
        cal.set(Calendar.SECOND, 0);
        cal.set(Calendar.MILLISECOND, 0);
        return cal.getTime();
    }
}
